Package i2p :: Module samclasses :: Class StringBuffer
[show private | hide private]
[frames | no frames]

Class StringBuffer

Deque --+
        |
       StringBuffer


A FIFO for characters. Strings can be efficiently appended to the end, and read from the beginning.

Example:
>>> B = StringBuffer('Hello W')
>>> B.append('orld!')
>>> B.read(5)
'Hello'

>>> B.read()
'World!'

Method Summary
  __init__(self, s)
  __len__(self)
Number of items in the deque.
  __repr__(self)
  __str__(self)
  append(self, s)
Append string data to the end of the buffer.
  peek(self, n)
Like read(), but do not remove the data that is returned.
  prepend(self, s)
Prepend string data to the beginning of the buffer.
  read(self, n)
Read n bytes of data (or less if less data available) from the beginning of the buffer.
    Inherited from Deque
  _partition(self)
  pop_first(self)
Pop an item off the beginning of the deque, and return it.
  pop_last(self)
Pop an item off the end of the deque, and return it.
  push_first(self, obj)
Prepend obj to the beginning of the deque.
  push_last(self, obj)
Append obj to the end of the deque.

Method Details

__len__(self)
(Length operator)

Number of items in the deque.
Overrides:
i2p.samclasses.Deque.__len__ (inherited documentation)

append(self, s)

Append string data to the end of the buffer.

peek(self, n=None)

Like read(), but do not remove the data that is returned.

prepend(self, s)

Prepend string data to the beginning of the buffer.

read(self, n=None)

Read n bytes of data (or less if less data available) from the beginning of the buffer. The data is removed. If n is omitted, read the entire buffer.

Generated by Epydoc 2.1 on Mon Aug 02 01:07:41 2004 http://epydoc.sf.net